package com.sky.config;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
public class RedisConfig {
    /*
     * 配置RedisTemplate
     * */
    @Bean
    public RedisTemplate<T, T> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<T, T> template = new RedisTemplate<>();
        template.setConnectionFactory(redisConnectionFactory);
        // Key 使用 String 序列化
        template.setKeySerializer(new StringRedisSerializer());
        template.setHashKeySerializer(new StringRedisSerializer());

        template.afterPropertiesSet();
        return template;
    }
}
